function $(_id){
	return document.getElementById(_id);
}

///////////数据定义，包括了文字，链接和图片地址等/////////////

///////////左侧导航链接///////////////////
var menuHrefs = new Array(13);






















<!-- 片花连接-->




menuHrefs[0] = {
	text: "索尼专区",
	url: "/a?u=RDIPTV_HZHX_IPS_02133041934619859&f=iptvtest_001_011_021"
};
menuHrefs[1] = {
	text: "华纳专区",
	url: "/a?u=RDIPTV_HZHX_IPS_02133041934619859&f=iptvtest_001_011_005"
};
menuHrefs[2] = {
	text: "包月专区",
	url: "/a?u=RDIPTV_HZHX_IPS_02133041934619859&f=iptvtest_001_011_020"
};
menuHrefs[3] = {
	text: "环球专区",
	url: "/a?u=RDIPTV_HZHX_IPS_02133041934619859&f=42645"
};
menuHrefs[4] = {
	text: "票房风云",
	url: "movie_list.htm"
};
menuHrefs[5] = {
	text: "最新上线",
	url: "/a?u=RDIPTV_HZHX_IPS_02133041934619859&f=iptvtest_001_011_002"
};
menuHrefs[6] = {
	text: "院线速递",
	url: "/a?u=RDIPTV_HZHX_IPS_02133041934619859&f=iptvtest_001_011_017_001"
};
menuHrefs[7] = {
	text: "特约影院",
	url: "/a?u=RDIPTV_HZHX_IPS_02133041934619859&f=iptvtest_001_011_004"
};
menuHrefs[8] = {
	text: "动作警匪",
	url: "/a?u=RDIPTV_HZHX_IPS_02133041934619859&f=iptvtest_001_011_007"
};
menuHrefs[9] = {
	text: "文艺剧情",
	url: "/a?u=RDIPTV_HZHX_IPS_02133041934619859&f=iptvtest_001_011_008"
};
menuHrefs[10] = {
	text: "科幻灾难",
	url: "/a?u=RDIPTV_HZHX_IPS_02133041934619859&f=iptvtest_001_011_009"
};
menuHrefs[11] = {
	text: "喜剧幽默",
	url: "/a?u=RDIPTV_HZHX_IPS_02133041934619859&f=iptvtest_001_011_010"
};
menuHrefs[12] = {
	text: "恐怖悬疑",
	url: "/a?u=RDIPTV_HZHX_IPS_02133041934619859&f=iptvtest_001_011_011"
};
menuHrefs[13] = {
	text: "战争史诗",
	url: "/a?u=RDIPTV_HZHX_IPS_02133041934619859&f=iptvtest_001_011_012"
};
menuHrefs[14] = {
	text: "儿童动漫",
	url: "/a?u=RDIPTV_HZHX_IPS_02133041934619859&f=iptvtest_001_011_014"
};

menuHrefs[15] = {
	text: "怀旧经典",
	url: "/a?u=RDIPTV_HZHX_IPS_02133041934619859&f=iptvtest_001_011_015"
};


///////////中间大图————————区域链接///////////////////
var picHrefs = new Array(4);

	<!--.取到海报图片.-->
	
	
			
				
					
				
			
				
			
				
			
				
			
				
			
				
					
				
			
				
			
				
			
			<!--.取海报图片结束.-->
			<!--.设置图片路径.-->
			
				
			
			
picHrefs[0] = {
	small: "http://125.210.227.11:8080/data/pic///20111022/movie/176_342/s59.jpg",
};

	<!--.取到海报图片.-->
	
	
			
				
			
				
					
				
			
				
			
				
			
				
			
			<!--.取海报图片结束.-->
			<!--.设置图片路径.-->
			
				
			
			
picHrefs[1] = {
	small: "http://125.210.227.11:8080/data/pic//data/pic/201112/20111214102248_shishangnvmotoudatupian_3429191811323938116124.jpg",
};

	<!--.取到海报图片.-->
	
	
			
				
			
				
			
				
			
				
					
				
			
				
			
			<!--.取海报图片结束.-->
			<!--.设置图片路径.-->
			
				
			
			
picHrefs[2] = {
	small: "http://125.210.227.11:8080/data/pic//data/pic/201201/20120118104613_mojiesanbuqujinrireying_3517104651327052975233.jpg",
};

	<!--.取到海报图片.-->
	
	
			
				
					
				
			
				
			
				
			
				
			
			<!--.取海报图片结束.-->
			<!--.设置图片路径.-->
			
				
			
			
picHrefs[3] = {
	small: "http://125.210.227.11:8080/data/pic//data/pic/20111004060613_xiaoshizaidiqijiejinrireying_327180394.jpg",
};

///////////中间下面新闻————————区域链接///////////////////
var movieHrefs = new Array(12);




movieHrefs[0] = {
	text: getSubStr("国王的演讲",6),
	url: "http://utc.hzdtv.tv:80/a?t=36&u=RDIPTV_HZHX_IPS_02133041934619859&f=iptvtest_001_019_005&a=2022627"
};
movieHrefs[1] = {
	text: getSubStr("时尚女魔头",6),
	url: "http://utc.hzdtv.tv:80/a?t=36&u=RDIPTV_HZHX_IPS_02133041934619859&f=iptvtest_001_019_005&a=3350430"
};
movieHrefs[2] = {
	text: getSubStr("魔戒三部曲:王者再临",6),
	url: "http://utc.hzdtv.tv:80/a?t=36&u=RDIPTV_HZHX_IPS_02133041934619859&f=iptvtest_001_019_005&a=3972466"
};
movieHrefs[3] = {
	text: getSubStr("消失在第七街",6),
	url: "http://utc.hzdtv.tv:80/a?t=36&u=RDIPTV_HZHX_IPS_02133041934619859&f=iptvtest_001_019_005&a=2029946"
};
//关键词栏目
//热浪球爱战


<!--  电影热点下的子栏目 -->










movieHrefs[4] = {
	text: "战马",
	url: "/a?u=RDIPTV_HZHX_IPS_02133041934619859&f=43266"
};

movieHrefs[5] = {
	text: "南京大屠杀",
	url: "/a?u=RDIPTV_HZHX_IPS_02133041934619859&f=iptvtest_001_019_005_016"
};

movieHrefs[6] = {
	text: "反殖民主义斗争",
	url: "/a?u=RDIPTV_HZHX_IPS_02133041934619859&f=43219"
};


movieHrefs[7] = {
	text: "",
	url: "/a?u=RDIPTV_HZHX_IPS_02133041934619859&f=iptvtest_001_011_018"
};

movieHrefs[8] = {
	text: "刘德华",
	url: "/a?u=RDIPTV_HZHX_IPS_02133041934619859&f=iptvtest_001_011_019_004"
};

movieHrefs[9] = {
	text: "动物总动员",
	url: "/a?u=RDIPTV_HZHX_IPS_02133041934619859&f=iptvtest_001_011_019_005"
};

movieHrefs[10] = {
	text: "源代码",
	url: "/a?u=RDIPTV_HZHX_IPS_02133041934619859&f=iptvtest_001_011_019_006"
};

movieHrefs[11] = {
	text: "",
	url: "/a?u=RDIPTV_HZHX_IPS_02133041934619859&f=iptvtest_001_019_005"
};

///////////中间底部公告滚动字幕————————区域链接///////////////////

var gonggaoText = "索尼电影版《蓝精灵》欢乐上映，唤儿时回忆";


///////////中间----搜索按钮————————区域链接///////////////////
var searchHref = "http://utc.hzdtv.tv:80/templates/iptvtest/runtime/iptv0712/common/search.jsp?u=RDIPTV_HZHX_IPS_02133041934619859&backUrl="+window.location.href+"&indexUrl=http://utc.hzdtv.tv:80/folder/iptvtest/RDIPTV_HZHX_IPS_02133041934619859/iptvtest_001.page&folderCode=iptvtest_001_011";

///////////首页按钮————————区域链接///////////////////
var shouyeHref = "http://utc.hzdtv.tv:80/folder/iptvtest/RDIPTV_HZHX_IPS_02133041934619859/iptvtest_001.page";

/////duration
var cssDuration = "300ms"; 
var blackColor = "#000000";
var whiteColor = "#ffffff";
////////////逻辑开始/////////////
var menusLen = menuHrefs.length;
var menus = new Array(menusLen);
for(var i=0; i<menusLen; i++){
	menus[i] = 0;
}
menus[0] = 155;
menus[1] = 210;
menus[2] = 265;
menus[3] = 320;
menus[4] = 375;
menus[5] = 430;
menus[6] = 485;
menus[7] = 540;
menus[8] = 595;

var first_index = 0, last_index = 8, sel_index = 4, max_index=menus.length-1, scaleTop=30;
var top_inc = menus[first_index+1] - menus[first_index];
var	first_top = menus[first_index];
var	last_top = menus[last_index];
var sel_top = menus[sel_index];

function incMenus(inc) {
	for ( var i = 0; i < menus.length; i++) menus[i] += inc;
}
function getMenuHtml(__index, __top, __text){
	return '<div id="menu'+__index+'" style="top:'+__top+'px;opacity:0;visibility:hidden;">'+__text+'</div>';
}
function scaleIn(_item){
	_item.style.lineHeight = "55px";
	_item.style.fontSize = "28px";
	_item.style.fontWeight=" 200";
	_item.style.color = "#000";
	_item.style.zIndex = 0;////////#1024修改
}
function scaleOut(_item){
	_item.style.lineHeight = "100px";
	_item.style.fontSize = "40px";
	_item.style.fontWeight="200";
	_item.style.color = "#CE0262";
	_item.style.zIndex = 100;////////#1024修改
}
function incIndex(_index, _inc){
	var __index = _index + _inc;
	if (__index > max_index) {
		__index -= menus.length;
	}
	if (__index < 0) {
		__index += menus.length;
	}
	return __index;
}
function selUp(){
	var _up = [];
	var _index = first_index;
	while(_index != sel_index){
		_up.push(_index);
		_index = incIndex(_index, 1);
	}
	return _up;
}
function selDown(){
	var _down = [];
	var _index = last_index;
	while(_index != sel_index){
		_down.push(_index);
		_index = incIndex(_index, -1);
	}
	return _down;
}
function inArr(_arr, _value){
	for(var i=0; i<_arr.length; i++){
		if(_arr[i] == _value){
			return true;
		}
	}
	return false;
}

function initMenus(){
	var _up = selUp();
	var _down = selDown();
	var _first = incIndex(first_index, -1);
	var _last = incIndex(last_index, 1);
	var htmls = [];
	for ( var i = 0; i < menus.length; i++) {
		var _top = menus[i];
		if(inArr(_up, i)){
			_top -= scaleTop;
			_opa = 1;
		} else if(inArr(_down, i)){
			_top += scaleTop;
			_opa = 1;
		} else if(i == sel_index){
			_top -= scaleTop - 5;
			_opa = 1;
		} else if(i == _first){
			_top = first_top - top_inc - scaleTop;
		} else if(i == _last){
			_top = last_top + top_inc + scaleTop;
		} else {
			_top = sel_top;
		}
		htmls.push(getMenuHtml(i, _top, menuHrefs[i].text));
	}
	var allMenuHTML = htmls.join("");
	$("menu_container").innerHTML = allMenuHTML;
	
	setTimeout(refreshMenus, 300);
}

function refreshMenus() {
	var _up = selUp();
	var _down = selDown();
	var _first = incIndex(first_index, -1);
	var _last = incIndex(last_index, 1);
	for ( var i = 0; i < menus.length; i++) {
		var _top = menus[i];
		var _opa = 0;
		var _m = getM(i);
		if(inArr(_up, i)){
			_m.style.visibility = "visible";
			_top -= scaleTop;
			_opa = 1;
			scaleIn(_m);
		} else if(inArr(_down, i)){
			_m.style.visibility = "visible";
			_top += scaleTop;
			_opa = 1;
			scaleIn(_m);
		} else if(i == sel_index){
			_m.style.visibility = "visible";
			_top -= scaleTop - 5;
			_opa = 1;
			scaleOut(_m);
		} else if(i == _first){
			_top = first_top - top_inc - scaleTop;
		} else if(i == _last){
			_top = last_top + top_inc + scaleTop;
		} else {
			_top = sel_top;
		}
		_m.style.top = _top + "px";
		_m.style.opacity = _opa;
	}
} 
function hid0(){
	$("crystal_float").style.opacity = 0;
	$("menu"+sel_index).style.opacity = 1;
	$("menu"+sel_index).style.color = "#505050";
}
function show0(){
	$("crystal_float").style.opacity = 1;
	$("menu"+sel_index).style.color = "#CE0262";
}

function getM(_index) {
	return $("menu" + _index);
}
function incFirstIndex(_inc) {
	first_index = incIndex(first_index, _inc);
}
function incLastIndex(_inc) {
	last_index = incIndex(last_index, _inc);
}
function incSelIndex(_inc) {
	sel_index = incIndex(sel_index, _inc);
}
var isMenuAnimate = false;
function down0() {
	if (isMenuAnimate)
		return;
	isMenuAnimate = true;

	//整体上移
	incMenus(-top_inc);
	//修改index
	incLastIndex(1);
	incFirstIndex(1);
	incSelIndex(1);
	//设置新的last对象的top和opacity
	menus[last_index] = last_top;
	//更新界面
	refreshMenus();
	isMenuAnimate = false;
	return true;
}
function up0() {
	if (isMenuAnimate)
		return;
	isMenuAnimate = true;

	//整体下移
	incMenus(top_inc);
	//修改index
	incLastIndex(-1);
	incFirstIndex(-1);
	incSelIndex(-1);
	//设置新的last对象的top和opacity
	menus[first_index] = first_top;
	//更新界面
	refreshMenus();
	isMenuAnimate = false;
	return true;
}

function sel0() {
	window.location.href = menuHrefs[sel_index % menuHrefs.length].url;
}
///////////////图片区域
////////////////////电影区域

/*var movies = [
	{t: 550, l:280, c: blackColor},
	{t: 550, l:460, c: blackColor},
	{t: 550, l:640, c: blackColor},
	{t: 595, l:280, c: blackColor},
	{t: 595, l:460, c: blackColor},
	{t: 595, l:640, c: blackColor},
];*/
var  movies= [
	{t: 132, l:280, c: blackColor},
	{t: 132, l:458, c: blackColor},
	{t: 132, l:636, c: blackColor},
	{t: 132, l:837, c: blackColor},
	{t: 550, l:280, c: blackColor},
	{t: 550, l:460, c: blackColor},
	{t: 550, l:640, c: blackColor},
	{t: 542, l:830, c: blackColor},
	{t: 595, l:280, c: blackColor},
	{t: 595, l:460, c: blackColor},
	{t: 595, l:640, c: blackColor},
	{t: 587, l:830, c: blackColor}
];
var movie_list = 0, max_movie_list = 2, list_movie_count = 4;
var movie_index = 0, max_movie_index = movieHrefs.length - 1;
var initMovieTop = movies[0].t-10, movieFloatTop = initMovieTop, movieTopInc = movies[list_movie_count].t - movies[1].t;
var initMovieLeft = movies[0].l+2, maxMoiveLeft=movies[list_movie_count-1].l - 2, movieFloatLeft = initMovieLeft, movieLeftInc = movies[1].l - movies[0].l+1;
var movieFloatOpacity = 0;
var movieTimeout;
function clearTimer(){
	if(movieTimeout != null){
		clearTimeout(movieTimeout);
		movieTimeout = null;
	}
}
function refreshMovie(isInit){
	refreshSearch();

	for(var i=0; i<movieHrefs.length; i++){
		if(isInit){
			if(i != 7 || i != 11){
				$("movie"+i).innerHTML = movieHrefs[i].text;
			}
		}

		if(movies[i].c == whiteColor){
			clearTimer();
			var __text = $("movie"+i);
			movieTimeout = setTimeout(function(){__text.style.color = whiteColor}, 200);
		}else{
			$("movie"+i).style.color = movies[i].c;
		}
	}
	$("movie_item_float").style.top = movieFloatTop + "px";
	$("movie_item_float").style.left = movieFloatLeft + "px";
	if(movie_index == 7 || movie_index == 11){
		$("movie_item_float").style.opacity = 0;
	}else if(movie_index<4){
		$("movie_item_float").getElementsByTagName("img")[0].src="http://utc.hzdtv.tv:80/templates/iptvtest/runtime/iptv0712/images/mov/float_choose.png";
		$("movie_item_float").style.opacity = movieFloatOpacity;
	}else{
		$("movie_item_float").getElementsByTagName("img")[0].src="http://utc.hzdtv.tv:80/templates/iptvtest/runtime/iptv0712/images/mov/new/float_choose1.png";
		$("movie_item_float").style.opacity = movieFloatOpacity;
	}
}


function hid2(){
	clearTimer();
	movieFloatOpacity = 0;
	movies[movie_index].c = blackColor;
	refreshMovie();
	$("movie7").src = "http://utc.hzdtv.tv:80/templates/iptvtest/runtime/iptv0712/images/mov/search0.png";
	$("movie11").src = "http://utc.hzdtv.tv:80/templates/iptvtest/runtime/iptv0712/images/mov/search1.png";
}

function show2(){
	movieFloatOpacity = 1;
	movies[movie_index].c = whiteColor;
	refreshMovie();
}

function left2(){
	if(movie_index == 0){
		return false;
	}
	if((movie_index)%list_movie_count == 0){
		//向左到菜单
		return false;
	}else{
		movieFloatLeft -= movieLeftInc;
		movies[movie_index].c = blackColor;
		movie_index -= 1;
		movies[movie_index].c = whiteColor;
		refreshMovie();
		return true;
	}
}

function right2(){
	if(movie_index == max_movie_index){
		return false;
	}
	if(movie_index%list_movie_count == 3){
		//向右到搜索
		return false;
	}else{
		movieFloatLeft += movieLeftInc;
		movies[movie_index].c = blackColor;
		movie_index += 1;
		movies[movie_index].c = whiteColor;
		refreshMovie();
		return true;
	}
}

function up2() {
	if (movie_list > 0) {
		movieTopInc = movies[movie_list*4].t - movies[(movie_list-1)*4].t;
		movieFloatTop = movieFloatTop - movieTopInc;
		movies[movie_index].c = blackColor;
		movie_index = movie_index - list_movie_count;
		movie_list -= 1;
		movies[movie_index].c = whiteColor;
		refreshMovie();
		return true;
	}
	return false;
}

function down2() {
	if ((movie_index + list_movie_count) <= max_movie_index) {
		movieTopInc = movies[(movie_list+1)*4].t - movies[movie_list*4].t;
		movieFloatTop = movieFloatTop + movieTopInc;
		movies[movie_index].c = blackColor;
		movie_index = movie_index + list_movie_count;
		movie_list += 1;
		movies[movie_index].c = whiteColor;
		refreshMovie();
		return true;
	}
	return false;
}

function sel2() {
	window.location.href = movieHrefs[movie_index].url;
}

/////search
function refreshSearch(){
	if(movie_index == 7){
		$("movie7").src = "http://utc.hzdtv.tv:80/templates/iptvtest/runtime/iptv0712/images/mov/search_f0.png";
		$("movie11").src = "http://utc.hzdtv.tv:80/templates/iptvtest/runtime/iptv0712/images/mov/search1.png";
	}else if(movie_index == 11){
		$("movie7").src = "http://utc.hzdtv.tv:80/templates/iptvtest/runtime/iptv0712/images/mov/search0.png";
		$("movie11").src = "http://utc.hzdtv.tv:80/templates/iptvtest/runtime/iptv0712/images/mov/search_f1.png";
	}else {
		$("movie7").src = "http://utc.hzdtv.tv:80/templates/iptvtest/runtime/iptv0712/images/mov/search0.png";
		$("movie11").src = "http://utc.hzdtv.tv:80/templates/iptvtest/runtime/iptv0712/images/mov/search1.png";	
	}
}


////首页
var shouye_pic_url = "http://utc.hzdtv.tv:80/templates/iptvtest/runtime/iptv0712/images/mov/shouye.png";

function refreshShouye(){
	$("shouye").src = shouye_pic_url;
}

function hid4(){
	shouye_pic_url = "http://utc.hzdtv.tv:80/templates/iptvtest/runtime/iptv0712/images/mov/shouye.png";
	refreshShouye();
}
function show4(){
	shouye_pic_url = "http://utc.hzdtv.tv:80/templates/iptvtest/runtime/iptv0712/images/mov/shouyeh.png";
	refreshShouye();
}
function sel4(){
	window.location.href = shouyeHref;
}

//gonggao
function refreshGonggao(){
	$("gonggao").innerText = gonggaoText;
}

/**
 * 0: menu
 * 1. small pics
 * 2. movie
 * 3. search
 * 4. shouye
 */
var area = 0;

//document.onirkeypress = grabEvent;
//document.onkeypress = grabEvent;
document.onsystemevent = grabEvent;
document.onkeypress = grabEvent;
document.onirkeypress = grabEvent;
document.onkeydown = grabEvent;
function grabEvent(event){
	var key_code = event.which;
		switch(key_code){
		case 372://page up
		case 1029:
			return 0;
			break;
		case 373://page down
		case 1028:
			return 0;
			break;
		case 1:
		case 38:
			up();
			return 0;
			break;
			
		case 2:
		case 40:
			down();
			return 0;
			break;
			
		case 3:
		case 37:
			left();
			return 0;
			break;
			
		case 4:
		case 39:
			right();
			return 0;
			break;
		
		case 13:
			sel();
			return 0;
			break;

		case 5202:
			media.AV.play();
			return 0;
			break;

	}
}

function up(){
	switch(area){
		case 0:
			up0();
			break;
		case 1:
			if(!up2()){
			    goArea(0);
			}
			break;
		case 2:
			goArea(1);
			break;
	}
}
function down(){
	switch(area){
		case 0:
			down0();
			break;
		case 1:
			if(!down2()){
			    goArea(2);
			}
			break;
	}
}
function left(){
	switch(area){
		case 0:
			break;
		case 1:
			if(!left2()){
			    goArea(0);
			}
			break;
		case 2:
			goArea(1);
			break;
	}
}
function right(){
	switch(area){
		case 0:
			goArea(1);
			break;
		case 1:
			if(!right2()) goArea(2);
			break;

	}
}
function goArea(_area){
	if(area == 0) hid0();
	if(area == 1) hid2();
	if(area == 2) hid4();

	area = _area;
	if(area == 0) show0();
	if(area == 1) show2();
	if(area == 2) show4();

}
function sel(){
	if(area == 0) sel0();
	if(area == 1) sel2();
	if(area == 2) sel4();

}

function init(){
	initMenus();
	for(var i = 0; i<picHrefs.length; i++){
		$("pic"+i).src = picHrefs[i].small;
		//$("picTitle"+i).innerHTML = picHrefs[i].text;
	}
	refreshMovie(true);
/*	refreshSearch();*/
	refreshShouye();
	refreshGonggao();
	//音频测试
	//jiayinpin();
} 

function jiayinpin(){
		//alert("111");
		media.AV.close();
		var rtsp_url = "rtsp://125.210.227.48:5542/hdds_ip/Video/20110715/1818620_20110713163906_r_315040724.ts?Contentid=155115242310480390810620221165108880590210120730&token=XXXX&duration=1_360000&isHD=0&isIpqam=0";
		media.AV.open(rtsp_url,'VOD');
		//media.video.fullScreen(); //全屏播放
		//media.video.setPosition(100,100,400,400);//指定位置、大小播放
		media.video.setPosition(0,0,1,1);
		
	}

function eixtPage(){
	media.AV.close();
}

function getSubStr(str,num){
    var num = num;
	if(str.length > num){
		str = str.substr(0,num)+"..";
	}
	return str;
}